<?php
namespace Home\Controller;
use Think\Controller;

class GamelogController extends Controller{
	
	//充值记录 by渠道
	public function chargeByChannel(){
		$html		=	"";
		$html		.=	"<tr><th>渠道名称</th><th>充值人数</th><th>充值次数</th><th>充值金额</th></tr>";
		$chargeLog	=	new \Home\Common\ChargeLog();
		$arResult	=	$chargeLog->getLogByChannel();
	
		foreach($arResult as $value){
			$html	.=	"<tr><td><a href='./channelCharge?channelid=".$value[0]."'>".C('channel_name.'.$value[0])."</a></td><td>".$value[1]."</td><td>".$value[2]."</td><td>".$value[3]."</td></tr>";
		}
	
		$this->assign("html",$html);
		$this->assign("chStyleli","chStyleli101");
		$this->assign("log1","chargeByChannel"); $this->assign("log2","chargeByServer");
		$this->display('index');
	
		session('mog_lastFun','../Gamelog/chargeByChannel');
	}
	
	//充值记录by区服
	public function chargeByServer(){
		$html		=	"";
		$html		.=	"<tr><th>区服名称</th><th>充值人数</th><th>充值次数</th><th>充值金额</th></tr>";
		$chargeLog	=	new \Home\Common\ChargeLog();
		$arResult	=	$chargeLog->getLogByServer($_SESSION['theDay']);
		foreach($arResult as $value){
			$html	.=	"<tr><td>".C('server_name.'.$value[0])."</td><td>".$value[1]."</td><td>".$value[2]."</td><td>".$value[3]."</td></tr>";
		}
		$this->assign("html",$html);
	
		$this->assign("chStyleli","chStyleli102");
		$this->assign("log1","chargeByChannel"); $this->assign("log2","chargeByServer");
		$this->display('index');
	
		session('mog_lastFun','../Gamelog/chargeByServer');
	}
	
	//指定渠道充值
	public function channelCharge(){
		$channelid	=	$_GET['channelid'];
		$date		=	session('mog_thedate');
		$html		=	"<tr><th>".C("channel_name.".$channelid)."</th><th>充值人数</th><th>充值次数</th><th>充值金额</th></tr>";
	
		$channelCharge	=	new \Home\Common\ChannelCharge();
	
		for($j=0;$j<10;$j++){
			$theDay		=	date('Y-m-d',strtotime($date."-".$j." days"));
			$arResult	=	$channelCharge->loadMembers($theDay,$channelid);
		}
	
		$html	.=	$channelCharge->getMembers();
	
		$this->assign("html",$html);
		$this->display('index');
	
		session('mog_lastFun','../Gamelog/channelCharge');
	}
	
	//等级记录
	public function getLevelLog(){
		$date	=	session('mog_thedate');
		$levelLog	=	new \Home\Common\LevelLog();
		$html	=	"";
		$html	.=	"<tr><th>D|L</th>"; for($i=1;$i<60;$i++){ $html.="<th>".$i."</th>";} $html.="</tr>";
	
		for($j=0;$j<10;$j++){
			$theDay		=	date('Y/m/d',strtotime($date."-".$j." days"));
			$arResult	=	$levelLog->getLevelLog($theDay);
	
			$html		.=	"<tr><td>".substr($theDay,5)."</td>";
				
			for($i=1;$i<60;$i++){
				if(!isset($arResult[$i]))	$arResult[$i]	=	0;
				if($arResult[$i] != 0) 		$arResult[$i] 	=	"<font color='#FF3333'>".$arResult[$i]."</font>";
				$html	.=	"<td class='leveltd'>".$arResult[$i]."</td>";
			}
				
			$html		.=	"</tr>";
		}
		$this->assign('servername',C("server_name.".I('session.serverid')));
		$this->assign("html",$html);
		$this->display('index');
		
		session('mog_lastFun','../Gamelog/getLevelLog');
	}
	
	//登陆统计 by渠道
	public function loginByChannel(){
		$html	=	"<tr><th>渠道名称</th><th>创建人数</th><th>登录人数</th><th>登录次数</th><th>空账号数据</th></tr>";
	
		$loginLog	=	new \Home\Common\LoginLog();
		$arResult	=	$loginLog->getChannelLog();
		foreach($arResult as $value){
			if(!isset($value[4])) $value[4] = 0;
			$html.="<tr><td>".C("channel_name.".$value[0])."</td><td>".$value[1]."</td><td>".$value[2]."</td><td>".$value[3]."</td><td>".$value[4]."</td></tr>";
		}
	
		$this->assign("html",$html);
		$this->assign("chStyleli","chStyleli101");
		$this->assign("log1","loginByChannel"); $this->assign("log2","loginByServer");
		$this->display('index');
	
		session('mog_lastFun','../Gamelog/loginByChannel');
	}
	
	//登陆统计 by区服
	public function loginByServer(){
		$html		=	"<tr><th>区服名称</th><th>创建人数</th><th>登录人数</th><th>登录次数</th><th>空账号数据</th></tr>";
	
		$loginLog	=	new \Home\Common\LoginLog();
		$arResult	=	$loginLog->getServerLog();
	
		foreach($arResult as $value){
			if(!isset($value[4])) $value[4]=0;
			$html.="<tr><td>".C("server_name.".$value[0])."</td><td>".$value[1]."</td><td>".$value[2]."</td><td>".$value[3]."</td><td>".$value[4]."</td></tr>";
		}
	
		$this->assign("html",$html);
		$this->assign("chStyleli","chStyleli102");
		$this->assign("log1","loginByChannel"); $this->assign("log2","loginByServer");
		$this->display('index');
	
		session('mog_lastFun','../Gamelog/loginByserver');
	}
	
	//任务统计记录
	public function getMission(){
		$html		=	"<tr><th>任务ID</th><th>任务名称</th><th>接受次数</th><th>完成次数</th></tr>";
		$missionLog	=	new \Home\Common\MissionLog();
		$arMissioin	=	$missionLog->getMissionLog();
		foreach($arMissioin as $key=>$value){
			$html.="<tr><td>".$value['missionid']."</td><td>".$key."</td><td>".$value['accept']."</td><td>".$value['achive']."</td></tr>";
			//$html.="<tr><td>".$key."</td><td></td><td>".$value['accept']."</td><td>".$value['achive']."</td></tr>";
		}
	
		$this->assign("html",$html);
		$this->display('index');
	
		session('mog_lastFun','../Gamelog/getMission');
	}
	
	//元宝消耗统计
	public function getConsume(){
		$html		=	"<tr><th>消耗类型</th><th>参与人数</th><th>参与次数</th><th>消耗元宝</th></tr>";
		$consumeLog	=	new \Home\Common\ConsumeLog();
		$arConsume	=	$consumeLog->getConsume();
	
		foreach($arConsume as $serverConsume){
			$html.="<tr><td>".C('consume_gold.'.$serverConsume[0]).'('.$serverConsume[0].')'."</td><td>".$serverConsume[1]."</td><td>".$serverConsume[2]."</td><td>".$serverConsume[3]."</td></tr>";
		}
	
		$this->assign('servername',C('server_name.'.$serverid));
		$this->assign('html',$html);
		$this->display('index');
	
		session('mog_lastFun','../Gamelog/getConsume');
	}
	
	//道具产出统计
	public function getPropGet(){
		$html			=	"<tr><th>物品ID</th><th>物品名称</th><th>获得人数</th><th>获得次数</th></tr>";
		$propGetLog		=	new \Home\Common\PropGetLog();
		$arPropGetLog	=	$propGetLog->getPropGetLog();
	
		foreach($arPropGetLog as $logInfo){
			$html.="<tr><td>".$logInfo[0]."</td><td>".$logInfo[1]."</td><td>".$logInfo[2]."</td><td>".$logInfo[3]."</td></tr>";
		}
	
		$this->assign('servername',C('server_name.'.$serverid));
		$this->assign('html',$html);
		$this->display('index');
	
		session('mog_lastFun','../Gamelog/getPropGet');
	
	}
	
	//留存统计 by渠道
	public function getSaveRate(){
		$html		="	<tr><th>日期</th><th>创建人数</th><th>1日留存</th><<th>3日留存</th>/<th>7日留存</th><th>14日留存</th><th>30日留存</th></tr>";
		$saveRate	=	new \Home\Common\SaveRate();
		$arSaveRate	=	$saveRate->getSaveRate();
	
		foreach($arSaveRate as $value){
			$html.="<tr><td>".$value['date']."</td><td>".$value['sum']."</td><td>".$value[1]."%</td><td>".$value[3]."%</td><td>".$value[7]."%</td><td>".$value[14]."%</td><td>".$value[30]."%</td></tr>";
		}
	
		$this->assign('html',$html);
		$this->assign("chStyleli","chStyleli101");
		$this->display('index');
	
		session('mog_lastFun','../Gamelog/getSaveRate');
	}
	
	//关卡统计
	public function getBarrierLog(){
		$html		=	"<tr><th>关卡名称</th><th>通过人数</th><th>通过次数</th><th>未通过人数</th><th>未通过次数</th></tr>";
		$barrier	=	new \Home\Common\BarrierLog();
		$arBarrier	=	$barrier->getBarrierLog();
	
		foreach($arBarrier as $key=>$value){
			if(!isset($value['scd']))	$value['scd']	=	0;
			if(!isset($value['sc']))	$value['sc']	=	0;
			if(!isset($value['fcd']))	$value['fcd']	=	0;
			if(!isset($value['fc']))	$value['fc']	=	0;
			$html.="<tr><td>".$key."</td><td>".$value['scd']."</td><td>".$value['sc']."</td><td>".$value['fcd']."</td><td>".$value['fc']."</td></tr>";
		}
	
		$this->assign('html',$html);
		$this->display('index');
	
		session('mog_lastFun','../Gamelog/getBarrierLog');
	}
	
}
